package com.zys.hotel_management.controller;


import com.zys.hotel_management.common.Response;
import com.zys.hotel_management.service.CheckInService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/checkin")
public class CheckInController {
    @Resource
    private CheckInService checkInService;

    @PostMapping("/{bookingId}/in")
    public Response<Void> checkIn(@PathVariable Integer bookingId) {
        try {
            checkInService.checkIn(bookingId);
            return Response.success(null);
        } catch (Exception e) {
            return Response.fail(500, "入住登记失败: " + e.getMessage());
        }
    }

    @PostMapping("/{bookingId}/out")
    public Response<Void> checkOut(@PathVariable Integer bookingId) {
        try {
            checkInService.checkOut(bookingId);
            return Response.success(null);
        } catch (Exception e) {
            return Response.fail(500, "退房登记失败: " + e.getMessage());
        }
    }
}